package com.appwoo.android.util;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

public class IOHelper
{
  public static void downloadAPK(String paramString)
    throws ClientProtocolException, IOException
  {
    String str = Environment.getExternalStorageDirectory().getPath() + "/download_cache";
    File localFile = new File(str);
    if (!localFile.exists())
      localFile.mkdir();
    HttpGet localHttpGet = new HttpGet(paramString);
    HttpResponse localHttpResponse = new DefaultHttpClient().execute(localHttpGet);
    InputStream localInputStream;
    FileOutputStream localFileOutputStream;
    byte[] arrayOfByte;
    if (localHttpResponse.getStatusLine().getStatusCode() == 200)
    {
      localInputStream = localHttpResponse.getEntity().getContent();
      localFileOutputStream = new FileOutputStream(str + "/txtw.apk");
      arrayOfByte = new byte[8192];
    }
    while (true)
    {
      int i = localInputStream.read(arrayOfByte);
      if (i == -1)
      {
        localFileOutputStream.close();
        localInputStream.close();
        return;
      }
      localFileOutputStream.write(arrayOfByte, 0, i);
    }
  }

  public static Bitmap getImage(String paramString)
    throws Exception
  {
    HttpURLConnection localHttpURLConnection = (HttpURLConnection)new URL(paramString).openConnection();
    localHttpURLConnection.setConnectTimeout(5000);
    localHttpURLConnection.setRequestMethod("GET");
    InputStream localInputStream = localHttpURLConnection.getInputStream();
    if (localHttpURLConnection.getResponseCode() == 200)
      return readBitMapStream(localInputStream);
    return null;
  }

  public static Bitmap readBitMapStream(InputStream paramInputStream)
    throws Exception
  {
    Bitmap localBitmap = BitmapFactory.decodeStream(paramInputStream);
    paramInputStream.close();
    return localBitmap;
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.android.util.IOHelper
 * JD-Core Version:    0.6.2
 */